package com.UBC417.termproject.Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Logger;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.UBC417.termproject.Data.User;

@SuppressWarnings("serial")
public class UnsubscribeServlet extends HttpServlet{
	private static final Logger log = Logger.getLogger(SubscribeServlet.class.getName());

	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException, ServletException {
		// Get parameters		
		String userID = req.getParameter("unsubEmail");
		String password = req.getParameter("unsubPassword");
		
		String forwardTo = "/account.jsp";

		User.Unsubscribe(userID, password);
		// redirect to user page
		ServletContext sc = getServletContext();
		RequestDispatcher rd = sc.getRequestDispatcher(forwardTo);
		rd.forward(req, resp);
			
	}	
	
}
